package com.bootcamp.java;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @program: ArrayCode
 * @description: output a string array length
 * @author: Keyu Li
 * @create: 2021-08-26 19:33
 **/

public class StringArray {
    public static void main(String[] args) {
        System.out.print("Input string array length: ");
        Scanner sc = new Scanner(System.in);
        int ll = Integer.parseInt(sc.nextLine());
        String[] str = new String[ll];
        for (int i = 0; i < ll; i++) {
            System.out.print("input the "+(i+1)+"th element: ");
            str[i] = sc.nextLine();
        }
        System.out.println("the string array length is "+str.length);
        if (!isNUllOrEmpty(str)) {
            iterateStringArray1(str);
            iterateStringArray2(str);
            iterateStringArray3(str);
        }
    }

    private static boolean isNUllOrEmpty(String[] str) {
        if (str == null) {
            System.out.println("null");
        }else if (str.length==0){
            System.out.println("[]");
        }else{
            return false;
        }
        return true;
    }

    private static void iterateStringArray3(String[] str) {
        System.out.print("[");
        for (String s : str) {
            System.out.print(s+", ");
        }
        System.out.print("\b\b]\n");
    }

    private static void iterateStringArray2(String[] str) {
        System.out.print("[");
        for (int i = 0; i < str.length; i++) {
            System.out.print(str[i]+", ");
        }
        System.out.print("\b\b]\n");
    }

    private static void iterateStringArray1(String[] str) {
        System.out.println(Arrays.toString(str));

        int[] arrAlpha = new int[3];
        int[] arrBeta = new int[]{1, 2, 3};
        int[] arrZeta = {1, 2, 3};

        int a = 5;
        int[] arr = new int[3];

    }
}
